package com.shop.usercenter.rest;


import com.shop.usercenter.entity.User;
import com.shop.usercenter.service.UserService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户管理
 *
 * @author chenye
 * @date 2020-0312
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    UserService userService;

    @PostMapping("/login")
    public ResponseEntity login(String name, String password) {
        return userService.login(name, password);
    }

    @PostMapping("/registy")
    public ResponseEntity registy(User user) {
        return ResponseEntity.ok().body(userService.addUser(user));
    }
}
